<?php

/**
 * sfAsset form base class.
 *
 * @method sfAsset getObject() Returns the current form's model object
 *
 * @package    symfony
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BasesfAssetForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'folder_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Folder'), 'add_empty' => false)),
      'filename'        => new sfWidgetFormInputText(),
      'description'     => new sfWidgetFormTextarea(),
      'author'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser01'), 'add_empty' => true)),
      'copyright'       => new sfWidgetFormInputText(),
      'type'            => new sfWidgetFormInputText(),
      'filesize'        => new sfWidgetFormInputText(),
      'small_width'     => new sfWidgetFormInputText(),
      'small_height'    => new sfWidgetFormInputText(),
      'large_width'     => new sfWidgetFormInputText(),
      'large_height'    => new sfWidgetFormInputText(),
      'original_width'  => new sfWidgetFormInputText(),
      'original_height' => new sfWidgetFormInputText(),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
      'slug'            => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'folder_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Folder'))),
      'filename'        => new sfValidatorString(array('max_length' => 255)),
      'description'     => new sfValidatorString(array('required' => false)),
      'author'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser01'), 'required' => false)),
      'copyright'       => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'type'            => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'filesize'        => new sfValidatorInteger(array('required' => false)),
      'small_width'     => new sfValidatorInteger(array('required' => false)),
      'small_height'    => new sfValidatorInteger(array('required' => false)),
      'large_width'     => new sfValidatorInteger(array('required' => false)),
      'large_height'    => new sfValidatorInteger(array('required' => false)),
      'original_width'  => new sfValidatorInteger(array('required' => false)),
      'original_height' => new sfValidatorInteger(array('required' => false)),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
      'slug'            => new sfValidatorString(array('max_length' => 255, 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'sfAsset', 'column' => array('folder_id', 'filename'))),
        new sfValidatorDoctrineUnique(array('model' => 'sfAsset', 'column' => array('slug'))),
      ))
    );

    $this->widgetSchema->setNameFormat('sf_asset[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'sfAsset';
  }

}
